JavaScript

A5.uconvertUnits Method

Syntax

A5.u.convertUnits(size,unit[,unitTo])

Arguments

sizenumberstring

The size to convert. If a number is passed in the second argument "unit" will be the units the size is in, and the third argument "unitTo" will be the units to convert the size to. If a string is passed in the units the size is in is expected to be in the string (for example "1.5in") and the second argument "unit" is the units to convert the size to.

unitstring

If a number is passed in for size, the units the size is in. If a string is passed in for size, the units to convert the size to. Values can be "px", "in", "pt", "pc", "cm" or "mm".

unitTostring

If a number is passed in for size, the units to convert the size to.

Returns

sizeOutnumber

The converted size.

Description

Convert a CSS size from one unit to another. Unit types that can be converted between are "px", "in", "pt", "pc", "cm" and "mm".

Example

var px = A5.u.convertUnits(1.5,'in','px');
var pt = A5.u.convertUnits('100px','pt');